package oop6.Task;

public class Teacher {
    public static void main(String[] args) {
        Teacher teacher = new Teacher("张三", "桃花小学", 20);
        try {
            teacher.selfInfo();
            if (teacher.getAge() < 22)
                throw new Exception();
        } catch (Exception e) {
            System.out.println("年龄小于22岁，有异常");
        }

    }

    private String name;
    private String school;
    private int age;

    public Teacher(String name, String school, int age) {
        this.name = name;
        this.school = school;
        this.age = age;
    }

    public void selfInfo() { //自我介绍
        System.out.println("我叫" + name + "，在" + school + "教书，年龄" + age + "岁");
    }

    public void giveLesson() {
        System.out.println("同学们，我们开始上课");
    }

    public int getAge() {
        return age;
    }

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }
}
